package com.huawei;

import java.util.LinkedHashSet;
import java.util.Scanner;

/**
 * //TODO 这道题和65题目，用动态规划写一遍
 相似题：65
 **/
public class HJ075 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String first = scanner.nextLine();
        String second = scanner.nextLine();

        LinkedHashSet<String> set1 = new LinkedHashSet<>();
        LinkedHashSet<String> set2 = new LinkedHashSet<>();
        LinkedHashSet<String> set = new LinkedHashSet<>();

        String LongStr = "";
        String shortStr = "";
        if (first.length()>second.length()) {
            LongStr=first;
            shortStr=second;
        }else{
            LongStr=second;
            shortStr=first;
        }


        for (int i = 0; i < LongStr.length(); i++) {
            for (int j = i + 1; j < LongStr.length() + 1; j++) {
                String str = LongStr.substring(i, j);
                set1.add(str);
            }
        }

        for (int i = 0; i < shortStr.length(); i++) {
            for (int j = i + 1; j < shortStr.length() + 1; j++) {
                String str = shortStr.substring(i, j);
                set2.add(str);
            }
        }

        for (String str : set2) {
            if (set1.contains(str)) {
                set.add(str);
            }
        }
        if(set.size()>0){
            String max = set.stream().max((o1, o2) -> o1.length() - o2.length()).get();
            System.out.println(max.length());
        }else{
            System.out.println(0);
        }



    }
}
